﻿using System.Collections.Generic;

namespace BorgExt.Startup
{
    [Plug("Borg.Analyzer"), Extension, Param("FileExtensions", ".dll")]
    public class AssemblyAnalyzer : ExtensionBase, IAnalyzer
    {
        public bool Analyze(string path, TypeBuilder typeBuilder,
            out ICollection<Contract> contracts, out ICollection<Plugin> plugins)
        {
            Contract contract;
            Plugin plugin;

            var flag = BorgExt.AssemblyAnalyzer.Analyze(path, typeBuilder,
                out contract, out plugin);

            contracts =
                contract != null
                ? new[] { contract }
                : new Contract[0];
            
            plugins =
                plugin != null
                ? new[] { plugin }
                : new Plugin[0];
            
            return flag;
        }
    }
}

